/**
 * 
 */
package com.study.jvm;

import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

/**
 * @author Administrator
 * @date 2019年6月29日
 */
public class ClassLoaderTest {
	
	public static void main(String [] args) throws Exception {
		
		URLClassLoader urlClassLoader1 = new URLClassLoader(new URL[]{new URL("file:///06java/workspace/study-demo/target/classes/com/study/jvm")});
		URLClassLoader urlClassLoader2 = new URLClassLoader(new URL[]{new URL("file:///06java/workspace/study-demo/target/classes/com/study/jvm")});
		
		Class<?> class1 = urlClassLoader1.loadClass("com.study.jvm.Dep");
		Class<?> class2 = urlClassLoader2.loadClass("com.study.jvm.Dep2");
		Object v1 = class1.getConstructor().newInstance();
		class1.getMethod("print").invoke(v1);
		
		System.out.println(class1.equals(class2));
		
		System.out.println(Thread.currentThread().getContextClassLoader());
		System.out.println(ClassLoader.getSystemClassLoader());
	}

}


